#把所有问题合并到data/question.json，以便随机


import json
import re

# with open('../data/data_include_question.json', 'r', encoding='utf-8') as file:
#     data = json.load(file)

with open('data/data_include_question.json', 'r', encoding='utf-8') as file:
    data = json.load(file)

question=[]
for book in data:
    related_questions = book.get('相关提问', '')
    if related_questions:
        qa_pairs = re.split(r'\n', related_questions)
        if qa_pairs:
            for qa in qa_pairs:
                if qa:
                    qa = re.sub(r'^\d+\.\s*问：', '', qa)
                    question.append(qa)
with open('data/question.json', 'w', encoding='utf-8') as json_file:
    json.dump(question, json_file, ensure_ascii=False)